package com.hand.demo.app.service.impl;

import io.choerodon.core.domain.Page;
import io.choerodon.mybatis.pagehelper.PageHelper;
import io.choerodon.mybatis.pagehelper.domain.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import com.hand.demo.app.service.HhrTaCategoryService;
import org.springframework.stereotype.Service;
import com.hand.demo.domain.entity.HhrTaCategory;
import com.hand.demo.domain.repository.HhrTaCategoryRepository;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 标签分类表(HhrTaCategory)应用服务
 *
 * @author
 * @since 2025-07-02 11:09:52
 */
@Service
public class HhrTaCategoryServiceImpl implements HhrTaCategoryService {
    @Autowired
    private HhrTaCategoryRepository hhrTaCategoryRepository;

    @Override
    public Page<HhrTaCategory> selectList(PageRequest pageRequest, HhrTaCategory hhrTaCategory) {
        return PageHelper.doPageAndSort(pageRequest, () -> hhrTaCategoryRepository.selectList(hhrTaCategory));
    }

    @Override
    public void saveData(List<HhrTaCategory> hhrTaCategorys) {
        List<HhrTaCategory> insertList = hhrTaCategorys.stream().filter(line -> line.getId() == null).collect(Collectors.toList());
        List<HhrTaCategory> updateList = hhrTaCategorys.stream().filter(line -> line.getId() != null).collect(Collectors.toList());
        hhrTaCategoryRepository.batchInsertSelective(insertList);
        hhrTaCategoryRepository.batchUpdateByPrimaryKeySelective(updateList);
    }
}

